sub_dict = {"lcase": "lower()", "ucase": "upper()", "strip": "strip()"}
special = ["print","return","swap"]  ##function calls not needing assignments like print
#plus minus times divby

def handle_function_sub(vname, fname, param_list):
    output = ""
    if len(param_list) == 0:
        newfname = sub_dict[fname]
        output = vname + " = " + vname + "." + newfname

    return output


def handle_function_fc(vname, fname, param_list):
    output = ""
    if len(param_list) == 0:
        if fname not in special:
            output = vname + " = " + "pav" + fname + "(" + vname + ")"
        if fname in special:
            output = fname + "(" + vname + ")"


    if len(param_list) > 0:
        parameter = ","
        for i in range(0, len(param_list)):
            if fname not in special:
                parameter += param_list[i] + ","
                parameter = parameter[:-1]
                output = vname + " = " + "pav" + fname + "(" + vname + parameter + ")"

        if fname in special:#for now its 'return' only
            for i in range(0, len(param_list)):
                parameter += param_list[i] + ","
            parameter = parameter[1:-1]
            output = fname+" "+parameter
            if fname == "swap":
                output = parameter + "=" + reverse(parameter)

    return output


def handle_function_ud(vname, fname, param_list):
    parameter = ""
    for i in range(0, len(param_list)):
        parameter += param_list[i] + ","
    parameter = parameter[:-1]
    output = vname + " = " + fname + "(" + parameter + ")"

    return output


# pavum functions

def pavleft(a, no):
    return a[:no]


def pavint(a):
    return int(a)


def pavstr(a):
    return str(a)

def pavplus(a,b):
    try:
        return a+b
    except:
        return str(a)+str(b)

def pavminus(a,b):
    return a-b

def pavtimes(a,b):
    try:
        return a*b
    except:
        a_new =""
        if type(a)=='str':
            for i in range(1,b):
                a_new += " " + a

def pavtimes(a,b):
    return a*b

def reverse(s):
  str = ""
  for i in s:
    str = i + str
  return str